# -*- coding:utf8 -*- #
# -----------------------------------------------------------------------------------
# ProjectName:  smart-meter-iot-test
# FileName:     select_updateCollector_sql.py
# Author  :     
# Datetime:     2023/4/7 23:46
# Description：水表数据随机构建
# -----------------------------------------------------------------------------------
import random

from common.util.timeUtil.timeUtil import get_now_time


class WaterData:
    # 用水增量
    @staticmethod
    def water_increment():
        nowNours = int(get_now_time(2))
        # 夜晚时间
        nighTime1 = random.randint(19, 23)
        nightTime2 = random.randint(8, 10)
        # 不上报
        doNoReport = random.randint(1, 10)
        waterIncrement = 0
        if doNoReport > 3:
            if nowNours >= nighTime1 or nowNours <= nightTime2:
                waterIncrement = round(random.uniform(0.05, 0.1), 2)
            else:
                waterIncrement = round(random.uniform(0.05, 0.2), 2)
        else:
            waterIncrement = waterIncrement
        return round(waterIncrement, 2)


if __name__ == '__main__':
    wd = WaterData()
    sumIncrement = 0
    for i in range(24):
        waterIncrement = wd.water_increment()
        print(f"第{i}次:{waterIncrement}")
        sumIncrement += waterIncrement
    print(f"累计: {sumIncrement}")
